using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using ComponentFactory.Krypton.Toolkit;
using System.IO;

namespace XemlInteractiveDesigner
{
    public partial class NewFromTemplateFrm : ComponentFactory.Krypton.Toolkit.KryptonForm
    {
        

        public string FileName
        {
            get { return (string)listViewTemplates.SelectedItems[0].Tag; }
           
        }

        public NewFromTemplateFrm()
        {
            InitializeComponent();
            listViewTemplates.SelectedIndexChanged += new EventHandler(listViewTemplates_SelectedIndexChanged);

            if (Directory.Exists(Properties.Settings.Default.TemplateFolder))
            {
                DirectoryInfo di = new DirectoryInfo(Properties.Settings.Default.TemplateFolder);
                foreach (FileInfo fi in di.GetFiles("*.xeml"))
                {
                    ListViewItem lvi = new ListViewItem();
                    lvi.Name = fi.Name;
                    lvi.Text = fi.Name.Replace("." + fi.Extension, "");
                    lvi.ImageIndex = 0;
                    lvi.Tag = fi.FullName;
                    this.listViewTemplates.Items.Add(lvi);
                }

            }
        }

        void listViewTemplates_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listViewTemplates.SelectedIndices.Count > 0)
                kryptonButtonOk.Enabled = true;
            else
                kryptonButtonOk.Enabled = false;
        }
    }
}